
#pragma once
#include <string>
#include <vector>
using namespace std;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
#define  CMD_LEN (9)

extern CString Seq_Space;
extern CString Port1_Space;
extern CString Port2_Space;
extern CString ExpMin_Space;
extern CString ExpMax_Space;
extern int CompleteLen; //seq to test method length.

extern const vector<CString> rangeStrVec;
class myUtil
{
public:
	static int mcuCom;
	static int mcuBaud;
	static int meterCom;
	static int meterBaud;
	static void getMcuComSets();
	static void setMcuComSets(int com, int baud);
	static void getMeterComSets();
	static void setMeterComSets(int com, int baud);
	static void crcCalc(uint8_t* pushMsg, uint8_t usDataLen, uint8_t* crcLo, uint8_t* crcHi);
	static void myLog(CString logInfo);
	static float getFloatFromEStr(CString eStr);
	static float transToRealLimit(std::string strLimit);
	static void parseRawCmd(CString cmd, int* port1, int* port2, float* downLimit, float* upLimit, float* rangeMax);
	static void parseToCmdStrPart(CString cmd, string* p1, string* p2, string* min, string* max, string* range);
	static int getPort1(CString cmd);
	static int getPort2(CString cmd);
	static float getTestDownLimit(CString cmd);
	static float getTestUpLimit(CString cmd);
	static CString getTestUpLimitStr(CString cmd);
	static float getTestSelRangeMax(CString cmd);
	static CString getTestSelRangeStr(CString cmd);
	static CString formatSeqStrMinMaxPart(CString str);
	static CString formatRangePart(CString str);
	static CString formatSeqStrPortPart(CString str);
	static void ConvertFile(LPCWSTR lpszFileIn, LPCWSTR lpszFileOut);
	static CString getCurPath();
	static void initDBTables();
	static void sqlExecute(string cmd);
	static int getWorkingGroup(string userName, string pwd);
	static void saveMcuComSets(CString port);
	static void saveMeterComSets(CString port);
	static CString completeStrLen(CString str, int lengMin);
	static void createPath(CString path);
	static void seqToTxt(CString seq, CString txt);
	static void txtToSeq(CString txt, CString seq);
	static CString csvToTxt(CString csv, CString txt);
	static void txtToCsv(CString txt, CString csv, CString pname);
	static string subreplace(string resource_str, string sub_str, string new_str);
	static void split(CString source, CStringArray& dest, CString division);
	static string formatStr33Split(float val);
	static string floatToStr(float val);
	static CString myUtil::SelectDirPath();
};


